package com.mls.fivedistrict.enums;

import com.baomidou.mybatisplus.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.io.Serializable;

/**
 * 投票状态
 * Created by chenxiuxiang on 2018/6/1.
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum VoteStatusEnum implements IEnum {
    PROGRESS("进行中", "progress"),
    FINISHED("已结束", "finished");
    private String desc;
    private String value;

    VoteStatusEnum(String desc, String value) {
        this.desc = desc;
        this.value = value;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Override
    public Serializable getValue() {
        return value;
    }

    @JsonCreator
    public static VoteStatusEnum getItem(String code) {
        for (VoteStatusEnum item : values()) {
            if (item.getValue().equals(code)) {
                return item;
            }
        }
        return null;
    }
}
